package o;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import androidx.annotation.NonNull;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.appmarket.service.installdepend.bean.GetDetailByIdResBean;
import com.huawei.appmarket.service.installdepend.bean.GetDetailByIdResBean$DetailInfoBean;
import com.huawei.appmarket.service.store.awk.bean.SubstanceDeeplinkCardBean;
import java.util.LinkedHashMap;
import java.util.List;
import o.ewm.n;

public class dww implements ewa {
    private static boolean ॱ = false;
    private cku ˊ;
    private Context ˋ;
    private SubstanceDeeplinkCardBean ˎ;
    private String ˏ;

    static class a {
        static void ˋ(String str, String str2, String str3, String str4, String str5) {
            LinkedHashMap linkedHashMap = new LinkedHashMap(4);
            linkedHashMap.put("deeplink", str2);
            linkedHashMap.put("ownerView", str3);
            linkedHashMap.put("ownerApp", str4);
            linkedHashMap.put("service_type", str5);
            dgh.ˋ(str, linkedHashMap);
        }
    }

    static class c implements IServerCallBack {
        private Context ˊ;
        private BaseDistCardBean ˎ;

        c(Context context, BaseDistCardBean baseDistCardBean) {
            this.ˊ = context;
            this.ˎ = baseDistCardBean;
        }

        public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
        }

        public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
            dww.ॱ = false;
            GetDetailByIdResBean getDetailByIdResBean = (GetDetailByIdResBean) responseBean;
            if (getDetailByIdResBean.getResponseCode() == 3) {
                evk.ˏ(this.ˊ, n.ʹˊ);
            } else if (getDetailByIdResBean.getResponseCode() == 0 && getDetailByIdResBean.getRtnCode_() == 0) {
                ˏ(getDetailByIdResBean);
            } else {
                evk.ˏ(this.ˊ, n.ᐝʼ);
            }
        }

        private void ˏ(GetDetailByIdResBean getDetailByIdResBean) {
            List ˏ = getDetailByIdResBean.ˏ();
            if (CollectCheck.isEmpty(ˏ)) {
                evk.ˏ(this.ˊ, n.ᐝʼ);
                return;
            }
            GetDetailByIdResBean$DetailInfoBean getDetailByIdResBean$DetailInfoBean = (GetDetailByIdResBean$DetailInfoBean) ˏ.get(0);
            if (getDetailByIdResBean$DetailInfoBean == null) {
                evk.ˏ(this.ˊ, n.ᐝʼ);
            } else if (getDetailByIdResBean$DetailInfoBean.ᐝॱ() != 0) {
                Logger.ˎ("SubstanceDeeplinkCardDialog", "can not download, app nonAdaptType is " + getDetailByIdResBean$DetailInfoBean.ᐝॱ());
                ॱ(this.ˊ, getDetailByIdResBean$DetailInfoBean.ʻ(), this.ˎ.u_());
            } else {
                try {
                    long parseLong = Long.parseLong(getDetailByIdResBean$DetailInfoBean.ʽ());
                    BaseDistCardBean baseDistCardBean = new BaseDistCardBean();
                    baseDistCardBean.ˏॱ(getDetailByIdResBean$DetailInfoBean.ॱॱ());
                    baseDistCardBean.ˋ(getDetailByIdResBean$DetailInfoBean.ˊॱ());
                    baseDistCardBean.ˏˎ(getDetailByIdResBean$DetailInfoBean.ʻ());
                    baseDistCardBean.ˉ(getDetailByIdResBean$DetailInfoBean.ॱˊ());
                    baseDistCardBean.ˊˋ(this.ˎ.u_());
                    baseDistCardBean.ॱ(parseLong);
                    baseDistCardBean.ॱᐝ(getDetailByIdResBean$DetailInfoBean.ˏॱ());
                    baseDistCardBean.ˋॱ(getDetailByIdResBean$DetailInfoBean.ˋॱ());
                    baseDistCardBean.ˊॱ(getDetailByIdResBean$DetailInfoBean.ᐝॱ());
                    baseDistCardBean.ˋᐝ(getDetailByIdResBean$DetailInfoBean.ᐝ());
                    baseDistCardBean.ॱ(getDetailByIdResBean$DetailInfoBean.ͺ());
                    baseDistCardBean.ˎ(getDetailByIdResBean$DetailInfoBean.ˎ());
                    baseDistCardBean.ॱ(getDetailByIdResBean$DetailInfoBean.ॱᐝ());
                    baseDistCardBean.ͺ(getDetailByIdResBean$DetailInfoBean.ʻॱ());
                    new dkd(this.ˊ).ˋ(new DownloadButton(this.ˊ), baseDistCardBean, cke.ˋ);
                } catch (Throwable e) {
                    evk.ˏ(this.ˊ, n.ᐝʼ);
                    Logger.ˋ("SubstanceDeeplinkCardDialog", "cannot format number", e);
                }
            }
        }

        private void ॱ(Context context, String str, String str2) {
            cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
            appDetailActivityProtocol.ˏ(new Request(drj.ॱ(str), str2));
            cjk.ˎ().ˋ(context, new cjm("appdetail.activity", appDetailActivityProtocol));
        }
    }

    public dww(@NonNull Context context, @NonNull SubstanceDeeplinkCardBean substanceDeeplinkCardBean, String str) {
        this.ˎ = substanceDeeplinkCardBean;
        this.ˋ = context;
        this.ˏ = str;
        this.ˊ = cku.ˋ(null, context.getString(n.ॱﾟ, new Object[]{substanceDeeplinkCardBean.ㆍ()}));
        this.ˊ.ॱ(-1, context.getString(n.ٴ));
        this.ˊ.ˋ(this);
    }

    public void ˏ() {
        this.ˊ.ˎ(this.ˋ);
    }

    private void ॱ(Context context) {
        if (!ॱ) {
            ॱ = true;
            cfw.ˎ(new eaj(this.ˎ.ᶥ()), new c(context, this.ˎ));
        }
    }

    private int ˎ() {
        int ॱ = ccz.ॱ();
        if (this.ˋ == null || !(this.ˋ instanceof Activity)) {
            return ॱ;
        }
        return dgm.ˎ((Activity) this.ˋ);
    }

    private void ˊ(Context context) {
        a.ˋ("340303", this.ˏ, this.ˎ.ॱॱ(), this.ˎ.ᶥ(), String.valueOf(ˎ()));
        ॱ(context);
    }

    private void ˊ() {
        a.ˋ("340304", this.ˏ, this.ˎ.ॱॱ(), this.ˎ.ᶥ(), String.valueOf(ˎ()));
    }

    public void ˏ(Activity activity, DialogInterface dialogInterface, int i) {
        if (-1 == i) {
            ˊ(activity);
        } else if (-2 == i) {
            ˊ();
        }
    }

    public void ˊ(Activity activity, DialogInterface dialogInterface) {
    }
}
